package com.zj.jdbc3Batis.service;

import com.zj.bean.UserInfo;
import com.zj.jdbc3Batis.tools.SingletonEnum;
import com.zj.jdbc3Batis.dao.UserDao;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

/**
 * service抛出异常，使用代理类来处理事务
 */
public class JdbcService2 {
    private UserDao userDao = SingletonEnum.INSTANCE.getUserDao();

    public List<UserInfo> doBusiness(UserInfo user, int id) throws SQLException {
        List<UserInfo> all = new ArrayList<>();

//        int a = userDao.updateUser(user, id);
//        System.out.println("修改数据条数：" + a);
        all = userDao.findUserBySexAndBir("0", "2018-05-02");
        List<String> names = userDao.findUserNameBySex("1");
        names.forEach(item -> System.out.println(item));
//            int a=1/0;
        return all;


    }
}
